//
//  CXLoginLodingView.m
//  TestFace2
//
//  Created by 曹想 on 2019/2/27.
//  Copyright © 2019 ShangHaiXinLaWangLuoKeji. All rights reserved.
//

#import "CXLoginLodingView.h"
#import "UIView+layer.h"
#import "UIColor+String.h"
#define KscreenWidth [[UIScreen mainScreen]bounds].size.width
#define KscreenHeight [[UIScreen mainScreen]bounds].size.height


@interface CXLoginLodingView ()

@property (weak, nonatomic) IBOutlet UIView *loginBottomView;

@property (weak, nonatomic) IBOutlet UIView *guestTopView;
@property (weak, nonatomic) IBOutlet UIButton *canleBtn;
@property (weak, nonatomic) IBOutlet UIButton *guestBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *cancleW;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *guestW;


@end

@implementation CXLoginLodingView


+(instancetype)shareInstanceView{
    
    return [[NSBundle mainBundle]loadNibNamed:@"CXLoginLodingView" owner:nil options:nil].lastObject;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.frame = CGRectMake(0, 0,KscreenWidth - 100 , 220);
    
    self.cancleW.constant = (KscreenWidth - 100 - 20*2 - 15)/2;
    self.guestW.constant = self.cancleW.constant;
    
    self.backgroundColor = [UIColor blackColor];
    self.alpha = 0.8;
    
    self.loginBottomView.backgroundColor = [UIColor blackColor];
    self.loginBottomView.alpha = 0.8;
    
    self.guestTopView.backgroundColor = [UIColor blackColor];
    self.guestTopView.alpha = 0.8;
    
    [self corners:UIRectCornerAllCorners Andsize:CGSizeMake(10, 10) withBorderColor:@""];
    
    [self.canleBtn layoutIfNeeded];
    [self.guestBtn layoutIfNeeded];
    
    
    self.canleBtn.backgroundColor = [UIColor hexStringColor:@"666666"];
    self.guestBtn.backgroundColor = [UIColor hexStringColor:@"666666"];
    
    [self.canleBtn corners:UIRectCornerAllCorners Andsize:CGSizeMake(4, 4) withBorderColor:@""];
    [self.guestBtn corners:UIRectCornerAllCorners Andsize:CGSizeMake(4, 4) withBorderColor:@""];
    
    //初始化的时候先隐藏guestTopView
    self.guestTopView.hidden = YES;
}

//face登录
- (IBAction)faceLogin:(UIButton *)sender {
    self.hidden = YES;
    if (self.delegate && [self.delegate respondsToSelector:@selector(faceLoginClick)]) {
        [self.delegate faceLoginClick];
    }
}


- (IBAction)guestLogin:(UIButton *)sender {
    self.guestTopView.hidden = NO;
    self.loginBottomView.hidden = YES;
}

- (IBAction)cancleClick:(UIButton *)sender {
    self.guestTopView.hidden = YES;
    self.loginBottomView.hidden = NO;
}

- (IBAction)guestClick:(UIButton *)sender {
    self.hidden = YES;
    if (self.delegate && [self.delegate respondsToSelector:@selector(guestLoginClick)]){
        [self.delegate guestLoginClick];
    }
}


@end
